<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?xml version="1.0" encoding="UTF-8"?>

<!-- todo -->
<!-- todo -->
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </meta>
  <link href="../css/theme.css" rel="stylesheet" type="text/css">
  </link>
  <link type="text/css" rel="stylesheet" href="../css/print.css" media="print">
  <title>结果展示</title>
  <script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
  <script type="text/javascript" src="../js/qm.core.js"></script>
  <script type="text/javascript" src="../js/qm.result.js"></script>
  <script type="text/javascript">
    var contextPath = '/qms';
    var obpmFilePath = '/obpm';
    function getQueryVariable(variable){
      var query = window.location.search.substring(1);
      var vars = query.split("&");
      for (var i = 0; i < vars.length; i++) {
          var pair = vars[i].split("=");
          if (pair[0] == variable) {
              return pair[1];
          }
      }
      return (undefined);
    }
    $(document).ready(function () {
      var id = getQueryVariable("id")
      $.ajax({
        url: obpmFilePath + '/magic-api/qms/answers/analysis?questionnaire_id='+ id,
        async: false,
        type: "GET",
        success: function (response) {
          if(response.errcode == 0){
            $(".analysis_details").find("#question").val(response.data[0].content);
            $(".analysis_details").find("#answer").val(response.data[0].answer);
            $(".analysis_details").find("#title").html(response.data[0].title)
            $(".analysis_details").find("#questionnaire_id").val(id)
            QM.result.init($("#question").val(), $("#answer").val());
          }
        }
      });
      //todo
      var val = QM.open;
      var total = QM.question;
      var correct = QM.correct;
      //生成分数栏
      if (val == true) {
        $div = $("<div style='margin-bottom: 10px;'></div>");
        $table = $("<table style='width:100%'></table>");

        $tr1 = $("<tr><td width='50%'>总分值</td><td width='50%'>个人得分</td></tr>");
        $score = $("<tr><td>0</td><td>0</td></tr>");

        $tr2 = $("<tr><td width='50%'>考题数</td><td width='50%'>答对数目</td></tr>");
        $question = $("<tr><td>" + total + "</td><td>" + correct + "</td></tr>");

        $("#analysis").append($div);
        $div.append($table);
        $table.append($tr1);
        $table.append($score);
        $table.append($tr2);
        $table.append($question);
      }
      var $button = $("#jump");
      $button.click(function () {
        var urlType = getQueryVariable("urlType");
        if(urlType == "HOMEPAGE"){
          window.location.href = "./home.html";
        }else{
          window.location.href = "./list.html";
        }
      });
    });
    
    function f1() {
      var obj = document.getElementById("contentResult");
      var content = obj.innerHTML;
      $("#i1").val(content);
      document.forms[0].submit();
    }

  </script>
</head>

<body style="overflow: auto;width: 100%;height: 90%;" class="analysis_details">
  <div style="background: #f5f5f5; height:65px;" class="noprint">
    <a id='jump' class='btn btn-primary'>返回</a>
    <a id='download' class='btn btn-primary_green' onclick="f1();" target="_blank" style="display:none;">下载</a>
    <a class='btn btn-primary_green btn-print' href='javascript:print();'>打印</a>
  </div>
  <tr>
    <td class="tdLabel"></td>
    <td><textarea name="content.content" cols="" rows="" id="question"
        style="display:none"></textarea>
    </td>
  </tr>
  <tr>
    <td class="tdLabel"></td>
    <td><textarea name="content.answer" cols="" rows="" id="answer"
        style="display:none"></textarea>
    </td>
  </tr>
  <tr style="display:none;">
    <td colspan="2">
      <input type="hidden" name="s_jumpType" value="HOMEPAGE" id="s_jumpType" />
    </td>
  </tr>

  <tr style="display:none;">
    <td colspan="2">
      <input type="hidden" name="content.id" value="zrAFQhm0bc5xfXafG6p" id="content_id" />
    </td>
  </tr>
  <tr style="display:none;">
    <td colspan="2">
      <input type="hidden" name="content.userId" value="__oP0irhWXGA2oZRusW1d" id="content_userId" />
    </td>
  </tr>
  <input type="hidden" id="_back_url_type" name="type" value="" />
  <input type="hidden" id="_back_url_status" name="status" value="" />
  <div id="contentResult" style="width: 100%;height: 98%;overflow: auto;">
    <div style="padding-bottom:10px;text-align: center; border-bottom: 3px #8ad748 solid;">
      <h1 id="title"></h1>
    </div>
    <div style='padding: 15px 0px 0px 15px; margin-bottom: 10px;border-bottom: 1px solid #f4f4f4;'>
      <div id="maiDiv" style="text-align:left"></div>
    </div>
  </div>
  <form action="download.action" method="post">
    <input type="hidden" id="_back_url_type" name="type" value="" />
    <input type="hidden" id="_back_url_status" name="status" value="" />
    <input id="i1" type="hidden" name="content" value="" />
  </form>
  <!-- todo -->
  <script language="javascript">
  </script>
</body>

</html>